import request from '@/utils/request'

// 获取文件夹树
export function listFiles() {
  return request({
    url: '/file/fileResources/treeList',
    method: 'post'
  })
}

/**
 * @params 获取路径下文件
 */
export function getFiles(data) {
  return request({
    url: `/file/fileResources/listObjects?fileId=${data.fileId}&recursive=${data.recursive}`,
    method: 'post'
  })
}

// 搜索文件
export function searchFiles(data) {
  return request({
    url: `/file/fileResources/searchFile?searchCode= + ${data.searchCode}&pathName=${data.pathName}`,
    method: 'post'
  })
}

// 上传文件
export function uploadFiles(data) {
  return request({
    url: '/file/fileResources/attachUpload',
    method: 'post',
    data
  })
}

// 复制文件
export function copyFiles(data) {
  return request({
    url: `/file/fileResources/copyObject?fileId=${data.fileId}&srcFileName=${data.srcFileName}&srcPathId=${data.srcPathId}`,
    method: 'post',
    data
  })
}

// 移动文件
export function moveFiles(data) {
  return request({
    url: `/file/fileResources/move?fileId=${data.fileId}&srcPathId=${data.srcPathId}`,
    method: 'post',
    data
  })
}

// 删除文件
export function delFiles(data) {
  return request({
    url: '/file/fileResources/objectDelete?fileIds=' + data,
    method: 'post'
  })
}

// 创建文件
export function addFiles(data) {
  return request({
    url: `/file/fileResources/putDirObject?fileId=${data.fileId}&objectName=${data.objectName}&remark=${data.remark}`,
    method: 'post'
  })
}

// 更新信息
export function updateFilesInfo(data) {
  return request({
    url: '/file/fileResources/updateInfo',
    method: 'post',
    data
  })
}

// 获取文件流
export function getAttachFile(data) {
  return request({
    url: '/file/fileResources/getAttachFile?fileId=' + data,
    responseType: 'blob',
    method: 'get'
  })
}

export function getFileListPage(data) {
  return request({
    url: '/file/fileResources/listObjectsPage',
    method: 'post',
    data
  })
}

export function addDownloadLog(params) {
  return request({
    url: '/file/attachFile/addDownloadLog',
    method: 'post',
    params
  })
}

// 文件申请新增
export function fileApplyAdd(data) {
  return request({
    url: '/file/apply/file/add',
    method: 'post',
    data
  })
}

// 文件申请删除
export function fileApplyDel(params) {
  return request({
    url: '/file/apply/file/delete',
    method: 'post',
    params
  })
}

export function fileAppDelList(params) {
  return request({
    url: '/file/apply/file/delete/batch',
    method: 'post',
    params
  })
}

// 文件申请获取
export function fileApplyGet(params) {
  return request({
    url: '/file/apply/file/get',
    method: 'get',
    params
  })
}

// 文件申请列表
export function fileApplyList(params) {
  return request({
    url: '/file/apply/file/list',
    method: 'get',
    params
  })
}

// 文件编辑更新

export function fileApplyUpdate(data) {
  return request({
    url: '/file/apply/file/update',
    method: 'post',
    data
  })
}

export function getListByBizIdAndTableName(params) {
  return request({
    url: '/file/attachFile/getListByBizIdAndTableName',
    method: 'post',
    params
  })
}
